
#line 1 "HARDWARE\PWM1\PWM.c" /0









 
  
#line 1 "HARDWARE\PWM1\PWM.h" /0









 
 
 
 
  
#line 1 ".\USER\User_Def.h" /0









 
 
 
 
 
  
#line 1 "\CODE\MC51F003A4_TEMPLETE\PWM_TEST\USER\MC51F003A4_COMMON.h" /0









 
 
 
 
 
  
#line 1 "C:\Program Files\Keil\SinoMCU_S1\Include\MC51F003A4.h" /0







 
 
 
 
 
 
 sfr PSW         = 0xD0;
 sfr DPS         = 0xD8;
 sfr ACC         = 0xE0;
 sfr B           = 0xF0;
 sfr AUXC        = 0xF1;
 sfr SP          = 0x81;
 sfr DPL         = 0x82;
 sfr DPH         = 0x83;
 sfr DPL1        = 0x84;
 sfr DPH1        = 0x85;
 sfr16 DPTR      = 0x82;
 sfr16 DPTR1     = 0x84;
 
 
 sfr PWRCR       = 0xF8;
 sfr OSCM        = 0xC0;
 sfr PCON        = 0x87;      
 sfr SLPCR       = 0x86;
 
 
 sfr RSTFLAG     = 0xE8;
 sfr WDTCR       = 0xCF;
 
 
 sfr P0          = 0x80;
 sfr P0MOD0      = 0xC1;
 sfr P0PU        = 0xC3;
 sfr P1          = 0x90;
 sfr P1MOD0      = 0x91;
 sfr P1MOD1      = 0x92;
 sfr P1PU        = 0x93;
 sfr P2          = 0xA0;
 sfr P2MOD0      = 0xA1;
 sfr P2MOD1      = 0xA2;
 sfr P2PU        = 0xA3;
 
 
 sfr TCON        = 0x88;
 sfr TMOD        = 0x89;
 sfr TL0         = 0x8A;
 sfr TL1         = 0x8B;
 sfr TH0         = 0x8C;
 sfr TH1         = 0x8D;
 sfr TCON1       = 0x8E;
 
 sfr T2CON       = 0xC8;
 sfr T2MOD       = 0xC9;
 sfr RCAPL2      = 0xCA;
 sfr RCAPH2      = 0xCB;
 sfr TL2         = 0xCC;
 sfr TH2         = 0xCD;
 sfr T2CON1      = 0xCE;
 
 sfr T3CR        = 0x8F;
 sfr TL3         = 0x96;
 sfr TH3         = 0x97;
 
 
 sfr PWM0CR      = 0xDD;
 sfr PWM0P       = 0xDE;
 sfr PWM0D       = 0xDF;
 
 sfr PWM1PH      = 0xE1;  
 sfr PWM1PL      = 0xE2;  
 sfr PWM1CR3     = 0xE3;  
 sfr PWM1CR2     = 0xE4;  
 sfr PWM1CR1     = 0xE5;  
 sfr PWM1CR0     = 0xE6;  
 sfr PWM1IER     = 0xE7;  
 sfr PWM12DH     = 0xE9;  
 sfr PWM12DL     = 0xEA;  
 sfr PWM101F     = 0xEB;  
 sfr PWM11DH     = 0xEC;  
 sfr PWM11DL     = 0xED;  
 sfr PWM10DH     = 0xEE;  
 sfr PWM10DL     = 0xEF;  
 sfr PWM15DH     = 0xF1;  
 sfr PWM15DL     = 0xF2;  
 sfr PWM14DH     = 0xF3;  
 sfr PWM14DL     = 0xF4;  
 sfr PWM123F     = 0xF5;  
 sfr PWM13DH     = 0xF6;  
 sfr PWM13DL     = 0xF7;  
 sfr PWM145F     = 0xFF;  
 
 
 sfr ADCCR0      = 0xF9;
 sfr ADCCR1      = 0xFA;
 sfr ADRIOS0     = 0xFB;
 sfr ADRIOS1     = 0xFC;
 sfr ADRL        = 0xFD;
 sfr ADRH        = 0xFE;
 sfr OSADJCR     = 0xFF;
 
 
 sfr SCON        = 0x98;
 sfr SBUF        = 0x99;
 sfr SADDR       = 0x9A;
 sfr SADEN       = 0x9B;
 sfr SCON_1      = 0x9C;
 sfr SBUF_1      = 0x9D;
 
 
 sfr SPCON       = 0xAD;
 sfr SPSTA       = 0xAE;
 sfr SPDAT       = 0xAF;
 
 
 sfr IE          = 0xA8;
 sfr IE1         = 0xA9;
 sfr EXTIS1      = 0xAB;
 sfr EXTEN1      = 0xAB;  
 sfr EXTIS       = 0xAC;
 sfr EXTEN       = 0xAC;  
 sfr IP          = 0xB8;
 sfr IPH         = 0xB9;
 sfr IP1         = 0xBA;
 sfr IPH1        = 0xBB;
 
 
 sfr LCDCR0      = 0xD9;
 sfr LCDSW       = 0xDA;
 
 
 sfr CRCCR       = 0xC1;  
 sfr CRCL        = 0xC2;  
 sfr CRCH        = 0xC3;  
 sfr CRCSTL      = 0xC4;  
 sfr CRCSTH      = 0xC5;  
 sfr CRCEDL      = 0xC6;  
 sfr CRCEDH      = 0xC7;  
 
 
 sfr IAPCR       = 0xE9;
 sfr IAPADL      = 0xEA;
 sfr IAPADH      = 0xEB;
 sfr IAPDB       = 0xEC;
 sfr IAPMD       = 0xEE;
 sfr IAPKEY      = 0xEF;
 
 
 
 sbit P01D       = P0^1;
 sbit P00D       = P0^0;
 
 sbit TF1        = TCON^7;
 sbit TR1        = TCON^6;
 sbit TF0        = TCON^5;
 sbit TR0        = TCON^4;
 sbit ADCIF      = TCON^0;
 
 sbit P17D       = P1^7;
 sbit P16D       = P1^6;
 sbit P15D       = P1^5;
 sbit P14D       = P1^4;
 sbit P13D       = P1^3;
 sbit P12D       = P1^2;
 sbit P11D       = P1^1;
 sbit P10D       = P1^0;
 
 sbit SM0        = SCON^7;
 sbit FE         = SCON^7;
 sbit SM1        = SCON^6;
 sbit RXOV       = SCON^6;
 sbit SM2        = SCON^5;
 sbit TXCOL      = SCON^5;
 sbit REN        = SCON^4;
 sbit TB8        = SCON^3;
 sbit RB8        = SCON^2;
 sbit TI         = SCON^1;
 sbit RI         = SCON^0;
 
 sbit P27D       = P2^7;
 sbit P26D       = P2^6;
 sbit P25D       = P2^5;
 sbit P24D       = P2^4;
 sbit P23D       = P2^3;
 sbit P22D       = P2^2;
 sbit P21D       = P2^1;
 sbit P20D       = P2^0;
 
 sbit EA         = IE^7;
 sbit ADCIE      = IE^6;
 sbit SPIIE      = IE^5;
 sbit UART0IE    = IE^4;
 sbit T1IE       = IE^3;
 sbit EXT1IE     = IE^2;
 sbit T0IE       = IE^1;
 sbit EXT0IE     = IE^0;
 
 sbit ADCIPL     = IP^6;
 sbit SPIIPL     = IP^5;
 sbit UART0IPL   = IP^4;
 sbit T1IPL      = IP^3;
 sbit EXT1IPL    = IP^2;
 sbit T0IPL      = IP^1;
 sbit EXT0IPL    = IP^0;
 
 sbit XTSPD      = OSCM^7;
 sbit STBH       = OSCM^5;
 sbit STBXT      = OSCM^4;
 sbit CLKS       = OSCM^2;
 sbit LFEN       = OSCM^1;
 sbit HFEN       = OSCM^0;
 
 sbit TF2        = T2CON^7;
 sbit EXTF2      = T2CON^6;
 sbit RCLKU0     = T2CON^5;
 sbit TCLKU0     = T2CON^4;
 sbit EX2EN      = T2CON^3;
 sbit TR2        = T2CON^2;
 sbit CT2        = T2CON^1;
 sbit CPRL2      = T2CON^0;
 
 sbit CY         = PSW^7;
 sbit AC         = PSW^6;
 sbit F0         = PSW^5;
 sbit RS1        = PSW^4;
 sbit RS0        = PSW^3;
 sbit OV         = PSW^2;
 sbit F1         = PSW^1;
 sbit P          = PSW^0;
 
 sbit SFRSL0     = DPS^6;
 sbit DIV16      = DPS^3;
 sbit MUL16      = DPS^2;
 sbit SEL        = DPS^0;
 
 sbit PORF       = RSTFLAG^7;
 sbit LVRF       = RSTFLAG^6;
 sbit RSTF       = RSTFLAG^5;
 sbit WDTRF      = RSTFLAG^4;
 sbit SWRF       = RSTFLAG^3;
 sbit SWRST      = RSTFLAG^0;  
 
 
 sbit E2_CLKEN   = PWRCR^6;
 sbit PWM1_CLKEN = PWRCR^5;
 sbit PWM0_CLKEN = PWRCR^4;
 sbit SPI_CLKEN  = PWRCR^3;
 sbit ADC_CLKEN  = PWRCR^2;
 sbit LCD_CLKEN  = PWRCR^1;
 sbit OCD_CLKEN  = PWRCR^0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 




 
#line 15 "\CODE\MC51F003A4_TEMPLETE\PWM_TEST\USER\MC51F003A4_COMMON.h" /0
 
  
#line 1 "C:\Program Files\Keil\C51\Inc\intrins.h" /0






 
 
 
 
 
 #pragma SAVE
 
 
#line 15 "C:\Program Files\Keil\C51\Inc\intrins.h" /1
 
 
 
#line 18 "C:\Program Files\Keil\C51\Inc\intrins.h" /0
 
 extern void          _nop_     (void);
 extern bit           _testbit_ (bit);
 extern unsigned char _cror_    (unsigned char, unsigned char);
 extern unsigned int  _iror_    (unsigned int,  unsigned char);
 extern unsigned long _lror_    (unsigned long, unsigned char);
 extern unsigned char _crol_    (unsigned char, unsigned char);
 extern unsigned int  _irol_    (unsigned int,  unsigned char);
 extern unsigned long _lrol_    (unsigned long, unsigned char);
 extern unsigned char _chkfloat_(float);
 
#line 29 "C:\Program Files\Keil\C51\Inc\intrins.h" /1
 
 
 
#line 32 "C:\Program Files\Keil\C51\Inc\intrins.h" /0
 
 extern void          _push_    (unsigned char _sfr);
 extern void          _pop_     (unsigned char _sfr);
 
 
 #pragma RESTORE
 
 
 
#line 16 "\CODE\MC51F003A4_TEMPLETE\PWM_TEST\USER\MC51F003A4_COMMON.h" /0
 
 
 typedef enum {RESET = 0, SET = !RESET} flagstatus, ITstatus;
 
 
 
 
 
 typedef   signed	char			int8_t;
 typedef   signed	int				int16_t;
 typedef   signed	long 			int32_t;
 
 typedef unsigned	char 			uint8_t;
 typedef unsigned	int 			uint16_t;
 typedef unsigned	long			uint32_t;
 typedef unsigned	char			u8;
 typedef unsigned	int 			u16;
 typedef unsigned	long			u32;
 typedef unsigned	char			uchar;
 typedef unsigned	int 			uint;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#line 15 ".\USER\User_Def.h" /0
 
  
#line 1 ".\HARDWARE\GPIO\GPIO.h" /0









 
 
 
 
  
#line 1 ".\USER\User_Def.h" /0









 
 
 
#line 13 ".\USER\User_Def.h" /1
  
 
  
  
  
  
  
  
 
 



 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
 
 
  
 
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
 
 
 
 
 
  
 
  
 
 
 
#line 124 ".\USER\User_Def.h" /0
 
 
 
#line 14 ".\HARDWARE\GPIO\GPIO.h" /0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 void GPIO_Init(void);
 
 
 
 
 
 
#line 16 ".\USER\User_Def.h" /0
 
  
#line 1 ".\HARDWARE\UART\UART.h" /0









 
 
 
  
#line 1 ".\USER\User_Def.h" /0









 
 
 
#line 13 ".\USER\User_Def.h" /1
  
 
  
  
  
  
  
  
 
 



 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
 
 
  
 
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
 
 
 
 
 
  
 
  
 
 
 
#line 124 ".\USER\User_Def.h" /0
 
 
 
#line 13 ".\HARDWARE\UART\UART.h" /0
 
  
#line 1 "C:\Program Files\Keil\C51\Inc\stdio.h" /0






 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 typedef unsigned int size_t;
 
 
 #pragma SAVE
 #pragma REGPARMS
 extern char _getkey (void);
 extern char getchar (void);
 extern char ungetchar (char);
 extern char putchar (char);
 extern int printf   (const char *, ...);
 extern int sprintf  (char *, const char *, ...);
 extern int vprintf  (const char *, char *);
 extern int vsprintf (char *, const char *, char *);
 extern char *gets (char *, int n);
 extern int scanf (const char *, ...);
 extern int sscanf (char *, const char *, ...);
 extern int puts (const char *);
 
 #pragma RESTORE
 
 
 
#line 14 ".\HARDWARE\UART\UART.h" /0
 



 
 
 
 
 void UART1_Init(void);
 char putchar(char tx_data);
 
 
 
 
 
#line 17 ".\USER\User_Def.h" /0
 
  
#line 1 ".\HARDWARE\PWM0\PWM0.h" /0









 
 
 
 
 
  
#line 1 ".\USER\User_Def.h" /0









 
 
 
#line 13 ".\USER\User_Def.h" /1
  
 
  
  
  
  
  
  
 
 



 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
 
 
  
 
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
 
 
 
 
 
  
 
  
 
 
 
#line 124 ".\USER\User_Def.h" /0
 
 
 
#line 15 ".\HARDWARE\PWM0\PWM0.h" /0
 
 
 void PWM0_User_Init(void);
 
 
 
 
#line 18 ".\USER\User_Def.h" /0
 
  
#line 1 "C:\Program Files\Keil\C51\Inc\stdio.h" /0






 
 
 
#line 10 "C:\Program Files\Keil\C51\Inc\stdio.h" /1
  
 
 
  
 
 
 
  
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#line 43 "C:\Program Files\Keil\C51\Inc\stdio.h" /0
 
#line 19 ".\USER\User_Def.h" /0
 
  
#line 1 "C:\Program Files\Keil\C51\Inc\stdarg.h" /0







 
 
 
 
 
 
 
#line 15 "C:\Program Files\Keil\C51\Inc\stdarg.h" /1
  
 
#line 17 "C:\Program Files\Keil\C51\Inc\stdarg.h" /0
 
 
 
 typedef char *va_list;
 
 
 
 
#line 25 "C:\Program Files\Keil\C51\Inc\stdarg.h" /1
  
 
 
#line 28 "C:\Program Files\Keil\C51\Inc\stdarg.h" /0
 
 
 
 
 
 
 
#line 20 ".\USER\User_Def.h" /0
 
 
 



 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 typedef union {
 unsigned char byte;
 struct
 {
 u8 bit0 : 1;
 u8 bit1 : 1;
 u8 bit2 : 1;
 u8 bit3 : 1;
 u8 bit4 : 1;
 u8 bit5 : 1;
 u8 bit6 : 1;
 u8 bit7 : 1;
 } bits;
 }bit_flag;
 extern volatile bit_flag flag1;
 extern volatile uint32_t millisecondTick;
 extern code uint16_t musicalScalFreq[21];
 
 
 void delay_ms(uint32_t ms);
 
 
 
 
 
#line 70 ".\USER\User_Def.h" /1
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
 
#line 92 ".\USER\User_Def.h" /0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 void mylog(const char *str, ...);
 
#line 118 ".\USER\User_Def.h" /1
  
 
#line 120 ".\USER\User_Def.h" /0
 
 
 
 
 
 
 
#line 14 "HARDWARE\PWM1\PWM.h" /0
 
 
 
 
 
 
 
 void PWM1_Init(void);
 void PWM1_SET_CHANNEL_10(uint16_t period, uint16_t pulse);
 void PWM1_SET_CHANNEL_10_PULSE( uint16_t pulse);
 void PWM1_OFF();
 void PWM1_SET_FREQ(uint16_t freq);
 void pwm1_set_freq_10(uint16_t freq);
 
 
 
 
#line 11 "HARDWARE\PWM1\PWM.c" /0
 
 
 static xdata uint16_t period;
 static xdata int32_t duty;
 static xdata int32_t dutySet;
 static xdata uint8_t exp = 20;
 static xdata uint16_t setFreq = 0;
 static xdata uint32_t stepSet = 0;
 static xdata int32_t dutyLpf=0;
 static xdata uint8_t dutyFlag = 0;
 static xdata uint32_t pwm1Cnt = 0;
 static xdata uint8_t step = 0;





 
 void PWM1_Init(void)
 {
 
  SFRSL0=1;				   
 
 
 PWM1CR1 &= ~0x80;  
 
 
 PWM1CR1 &= 0xf8;
 PWM1CR1 |= 0x00;																					   
 PWM1IER &= ~0x80; 
 
 PWM1CR0 |= (0x01);  
 
 PWM1PH = 1000 >> 8;
 PWM1PL = 1000 % 256;																				   
 PWM1CR2 |= 0x80;																			   
 PWM1CR2 &= ~(0x01 | 0x02 | 0x04);											   
 PWM1CR3 |= (0x01);  
 PWM1CR3 |= 0x80;																			   
 
 
#line 52 "HARDWARE\PWM1\PWM.c" /1
 
 
 
 
 
 
 
 
 
 
 
 
#line 64 "HARDWARE\PWM1\PWM.c" /0
 
 PWM1CR1 |= (0x10);  
 
 PWM10DH = 0;
 PWM10DL = 0;  
 
 
 
 
 
 
 
 
 
 
 
 
  SFRSL0=0;							   
 }
 
 void PWM1_SET_FREQ(uint16_t freq)
 {
 setFreq = freq;
 period = (8000000UL) / setFreq;
 dutySet = period / 2;
 stepSet = setFreq / 3; 
 duty = 10;
 dutyFlag = 0;
 exp = 5;
 
 
 PWM1_SET_CHANNEL_10(period, dutySet);
 
 }
 void pwm1_set_freq_10(uint16_t freq)
 {
  SFRSL0=1;				   
 PWM1CR0 &= ~0x80;   
 period = (8000000UL) / freq;
 PWM1PH = period >> 8;
 PWM1PL = period % 256;
 
 PWM10DH = (period/2) >> 8;
 PWM10DL = (period/2) % 256;  
 PWM1CR0 |= 0x80;   
  SFRSL0=0;				   
 }





 
 void PWM1_SET_CHANNEL_10(uint16_t period, uint16_t pulse)
 {
  SFRSL0=1;				   
 
 PWM1IER &= ~0x80;  
 
 
 PWM1CR0 &= ~0x80;   
 
 PWM1PH = period >> 8;
 PWM1PL = period % 256;
 
 PWM10DH = pulse >> 8;
 PWM10DL = pulse % 256;  
 
 
 
 PWM1CR0 |= 0x80;   
 
  SFRSL0=0;				   
 }
 
 void PWM1_SET_CHANNEL_10_PULSE(uint16_t pulse)
 {
  SFRSL0=1;				   
 
 
 
 
 
 PWM10DH = pulse >> 8;
 PWM10DL = pulse % 256;  
 
  SFRSL0=0;				   
 }
 void PWM1_OFF()
 {
  SFRSL0=1;				   
 PWM1CR0 &= ~0x80;   
  SFRSL0=0;				   
 }
 
 
 void PWM1_ISR(void) interrupt 9  
 {
  SFRSL0=1;				   
 PWM1IER &= ~0x80;  
 step = pwm1Cnt / (stepSet / 14); 
 pwm1Cnt++;
 
 switch (step)
 {
 case 0: duty = dutySet; break;
 case 1: duty = dutySet; break;
 case 2: duty = dutySet; break;
 case 3: duty = dutySet * 6 / 10; break;
 case 4: duty = dutySet * 5 / 10; break;
 case 5: duty = dutySet * 4 / 10; break;
 case 6: duty = dutySet * 3 / 10; break;
 case 7: duty = dutySet * 2 / 10; break;
 case 8: duty = dutySet * 1 / 10; break;
 case 9: duty = dutySet * 1 / 100; break;
 case 10: duty = dutySet * 1 / 100; break;
 case 11: duty = dutySet * 1 / 1000; break;
 case 12: duty = dutySet * 1 / 10000; break;
 case 13: duty = 0;
 default:
 PWM1CR0 &= ~0x80;   
 pwm1Cnt = 0;
 break;
 }
 
 dutyLpf += (duty - dutyLpf)/(dutySet/100);
 PWM10DH = (uint16_t)dutyLpf >> 8;
 PWM10DL = (uint16_t)dutyLpf % 256;  
 
  SFRSL0=0;                
 
 }
 void PWM1_FB_ISR(void) interrupt 12  
 {
 
 
 
 
 
 
 
 
 
 }
 
 
